package br.ufrj.dcc.mapaviolencia;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.quartz.SchedulerException;

import br.ufrj.dcc.mapaviolencia.util.LocalizacaoUtil;
import br.ufrj.dcc.mapaviolencia.util.QuartzUtil;

public class Bootstrap extends HttpServlet {

	private static final long serialVersionUID = 1L;

	@Override
	public void init(ServletConfig config) throws ServletException {
		
		//Carrega estados do banco
		LocalizacaoUtil.initialize();
		
		// init Quartz
		try {
            QuartzUtil.initialize();
            QuartzUtil.scheduleTwitterJob();
        } catch (SchedulerException e) {
            throw new ServletException(e);
        }
		
	}
	
	@Override
	public void destroy() {
		
		// shutdown Quartz
		try {
            QuartzUtil.shutdown();
        } catch (SchedulerException e) {
        	e.printStackTrace();
        }
	}
	
}
